<template>
  <div>
    <a-table
      :columns="columns"
      :data-source="inOrderTableData"
      :pagination="false"
      :scroll="{ x: 1500 }"
    >
      <!-- 结算时间-->
      <span slot="settlementTime" slot-scope="text, record">
        {{
          record.settlementTime === null || record.settlementTime === ""
            ? "暂无"
            : record.settlementTime.replace("T", " ")
        }}
      </span>
      <!-- 状态-->
      <span slot="state" slot-scope="text, record">
        <span style="color: #3eae7c">
          {{ record.state }}
        </span>
      </span>
      <!-- 接收时间-->
      <span slot="updateTime" slot-scope="text, record">
        {{
          record.updateTime === null || record.updateTime === ""
            ? "暂无"
            : record.updateTime.replace("T", " ")
        }}
      </span>
      <span slot="cost" slot-scope="text, record">
        {{ record.cost || "暂无" }}
      </span>
      <span slot="currency" slot-scope="text, record">
        {{ record.currency || "暂无" }}
      </span>
      <span slot="action" slot-scope="text, record">
        <a
          v-if="record.applyState != '80' && port != 'client'"
          href="javascript:;"
          style="text-decoration: underline; color: rgb(41, 41, 224)"
          @click="close(record)"
          >结算
        </a>
        <a-divider
          type="vertical"
          v-if="record.applyState != '80' && port != 'client'"
        />
        <a
          href="javascript:;"
          style="text-decoration: underline; color: rgb(41, 41, 224)"
          @click="costServiceInfo(record)"
          >账单详情
        </a>
      </span>
    </a-table>

    <!-- 服务项信息查看 -->
    <ServiceModalReap />
  </div>
</template>

<script>
import ServiceModalReap from "@/components/serviceModal/ServiceModalReap.vue";
import { validation_behalfStock } from "@/apis/system/auditCenter/IsCheck";
export default {
  props: [
    "inOrderTableData",
    "getInOrderTabData",
    "getInOrderTypeCount",
    "port",
  ],
  components: {
    ServiceModalReap,
  },
  data() {
    return {
      loading: false,
      rowData: {},
    };
  },
  methods: {
    //费用服务项信息查看
    costServiceInfo(record) {
      if (record.applyState === "110") {
        setTimeout(() => {
          this.$bus.$emit("reappearance", record, 2, record.key, true);
        }, 50);
      } else {
        setTimeout(() => {
          this.$bus.$emit("reappearance", record, 2, record.key, false);
        }, 50);
      }
    },
    //账单结算
    close(record) {
      let _this = this;
      this.$confirm({
        title: `确定要结算订单编号${record.applyCode}的数据吗?`,
        cancelText: "取消",
        okText: "确定",
        onOk() {
          return new Promise((resolve, reject) => {
            setTimeout(async () => {
              let { code } = await validation_behalfStock(record.key);
              if (code === "10000") {
                _this.getInOrderTabData();
                _this.getInOrderTypeCount();
                resolve();
              } else {
                reject();
              }
            }, 1000);
          }).catch(() => console.log("Oops errors!"));
        },
        onCancel() {},
      });
    },
  },
  computed: {
    columns() {
      return [
        {
          title: "入库仓库",
          dataIndex: "warehousingName",
          align: "center",
          scopedSlots: { customRender: "warehousingName" },
          width: "10%",

          //  fixed: "left",
        },
        {
          title: "订单编号",
          dataIndex: "applyCode",
          align: "center",
          scopedSlots: { customRender: "applyCode" },
          width: "9%",
        },
        {
          title: "客户编号",
          dataIndex: "tenantId",
          align: "center",
          width: "9%",
        },
        // {
        //   title: "SKU总数量（个）",
        //   dataIndex: "title",
        //   // ellipsis: true,
        //   scopedSlots: { customRender: "title" },
        //   align: "center",
        //   width: "9%",
        // },
        // {
        //   title: "SKU总重量（g）",
        //   dataIndex: "typeName",
        //   scopedSlots: { customRender: "typeName" },
        //   align: "center",
        //   width: "10%",
        //   // ellipsis: true,
        // },
        {
          title: "币种",
          dataIndex: "currency",
          scopedSlots: { customRender: "currency" },
          align: "center",
          width: "8%",
          // ellipsis: true,
        },
        {
          title: "费用",
          dataIndex: "cost",
          scopedSlots: { customRender: "cost" },
          align: "center",
          width: "9%",
        },
        {
          title: "状态",
          dataIndex: "state",
          scopedSlots: { customRender: "state" },
          align: "center",
          width: "9%",
        },

        {
          title: "接收时间",
          dataIndex: "updateTime",
          scopedSlots: { customRender: "updateTime" },
          align: "center",
          width: "9%",
        },
        {
          title: "结算时间 ",
          dataIndex: "settlementTime",
          align: "center",
          width: "9%",
          scopedSlots: { customRender: "settlementTime" },
          // ellipsis: true,
        },
        {
          title: "操作",
          dataIndex: "action",
          scopedSlots: { customRender: "action" },
          align: "center",
          width: "12%",
        },
      ];
    },
  },
};
</script>

<style lang="less" scoped>
</style>